<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <style>
        div {
            width: 200px;
            height: 200px;
            margin: 100px;
            background-color: red;
        }
    </style>
    
</head>
<body>

    <button>改变背景色</button>
    <div></div>
    <script src="./jquery-1.11.1.js"></script>
    <script src="./jquery.color.js"></script>
<script>
    $(function () {
        flag = true
        $('button').on('click',function(){
            // dom对象转换成jq对象
        
        if(flag===true){
            const change = {'background-color':'blue',
                          'width':500
        }
        $('div').animate(change,2000)
        flag = false
        }else{
            const change1 = {'background-color':'red',
                          'width':200
        }
            $('div').animate(change1,2000)
            flag = true
        }
        })
        
    })
</script>
</body>
</html>